home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Microsoft Plateform / Visual Basic 5.0 / Msvb50.ace / msvb50 / MSVB50 / VB / SAMPLES / VISDATA / LOGINFRM.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-10-16  |  4.2 KB  |  145 lines

  1. VERSION 5.00
  2. Begin VB.Form frmLogin 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "Login"
  5.    ClientHeight    =   1980
  6.    ClientLeft      =   2550
  7.    ClientTop       =   3330
  8.    ClientWidth     =   2820
  9.    BeginProperty Font 
  10.       Name            =   "Tahoma"
  11.       Size            =   8.25
  12.       Charset         =   0
  13.       Weight          =   400
  14.       Underline       =   0   'False
  15.       Italic          =   0   'False
  16.       Strikethrough   =   0   'False
  17.    EndProperty
  18.    HelpContextID   =   2016133
  19.    Icon            =   "LOGINFRM.frx":0000
  20.    LinkTopic       =   "Form1"
  21.    LockControls    =   -1  'True
  22.    ScaleHeight     =   1980
  23.    ScaleWidth      =   2820
  24.    ShowInTaskbar   =   0   'False
  25.    StartUpPosition =   2  'CenterScreen
  26.    Begin VB.CommandButton cmdCancel 
  27.       Cancel          =   -1  'True
  28.       Caption         =   "&Cancel"
  29.       Height          =   375
  30.       Left            =   1440
  31.       MaskColor       =   &H00000000&
  32.       TabIndex        =   3
  33.       Top             =   1440
  34.       Width           =   1215
  35.    End
  36.    Begin VB.CommandButton cmdOK 
  37.       Caption         =   "&OK"
  38.       Default         =   -1  'True
  39.       Height          =   375
  40.       Left            =   120
  41.       MaskColor       =   &H00000000&
  42.       TabIndex        =   2
  43.       Top             =   1440
  44.       Width           =   1215
  45.    End
  46.    Begin VB.TextBox txtPassword 
  47.       Height          =   285
  48.       Left            =   120
  49.       PasswordChar    =   "*"
  50.       TabIndex        =   1
  51.       Top             =   960
  52.       Width           =   2535
  53.    End
  54.    Begin VB.TextBox txtLoginName 
  55.       Height          =   285
  56.       Left            =   120
  57.       TabIndex        =   0
  58.       Top             =   360
  59.       Width           =   2535
  60.    End
  61.    Begin VB.Label lblLabels 
  62.       AutoSize        =   -1  'True
  63.       Caption         =   "Password: "
  64.       Height          =   195
  65.       Index           =   1
  66.       Left            =   120
  67.       TabIndex        =   5
  68.       Top             =   720
  69.       Width           =   795
  70.    End
  71.    Begin VB.Label lblLabels 
  72.       AutoSize        =   -1  'True
  73.       Caption         =   "Login Name: "
  74.       Height          =   195
  75.       Index           =   0
  76.       Left            =   120
  77.       TabIndex        =   4
  78.       Top             =   120
  79.       Width           =   930
  80.    End
  81. Attribute VB_Name = "frmLogin"
  82. Attribute VB_GlobalNameSpace = False
  83. Attribute VB_Creatable = False
  84. Attribute VB_TemplateDerived = False
  85. Attribute VB_PredeclaredId = True
  86. Attribute VB_Exposed = False
  87. Option Explicit
  88. '>>>>>>>>>>>>>>>>>>>>>>>>
  89. Const FORMCAPTION = "Login"
  90. Const BUTTON1 = "&OK"
  91. Const BUTTON2 = "&Cancel"
  92. Const Label1 = "Login Name:"
  93. Const Label2 = "Password:"
  94. '>>>>>>>>>>>>>>>>>>>>>>>>
  95. Private Sub cmdCancel_Click()
  96.   On Error Resume Next
  97.   'if the global workspace object is not set, then we must be
  98.   'opening the app so we should end
  99.   If gwsMainWS Is Nothing Then
  100.     End
  101.   Else
  102.     'just unload since the workspace is already set
  103.     Unload Me
  104.   End If
  105. End Sub
  106. Private Sub Form_Load()
  107.   Me.Caption = FORMCAPTION
  108.   cmdOK.Caption = BUTTON1
  109.   cmdCancel.Caption = BUTTON2
  110.   lblLabels(0).Caption = Label1
  111.   lblLabels(1).Caption = Label2
  112. End Sub
  113. Private Sub cmdOK_Click()
  114.   On Error GoTo OKErr
  115.   Dim wsp As Workspace
  116.   Dim sTmp As String
  117.   If Not gwsMainWS Is Nothing Then
  118.     If UCase(txtLoginName.Text) = UCase(gwsMainWS.UserName) Then
  119.       'same as current login name
  120.       Unload Me
  121.       Exit Sub
  122.     End If
  123.   End If
  124.   'set the new login name
  125.   DBEngine.DefaultUser = txtLoginName.Text
  126.   DBEngine.DefaultPassword = txtPassword.Text
  127.   Set wsp = DBEngine.CreateWorkspace("MainWS", txtLoginName.Text, txtPassword.Text)
  128.   'must have been successful so set the gswMainWS
  129.   Set gwsMainWS = wsp
  130.   Unload Me
  131.   Exit Sub
  132. OKErr:
  133.   MsgBox Error
  134.   txtLoginName.SetFocus
  135.   Exit Sub        'give them another chance
  136. End Sub
  137. Private Sub txtLoginName_GotFocus()
  138.   txtLoginName.SelStart = 0
  139.   txtLoginName.SelLength = Len(txtLoginName.Text)
  140. End Sub
  141. Private Sub txtPassword_GotFocus()
  142.   txtPassword.SelStart = 0
  143.   txtPassword.SelLength = Len(txtPassword.Text)
  144. End Sub
  145.